/**
 * Demonstrates a range of Button options the framework offers out of the box
 */
Ext.define('cloud.view.photoswall.PhotoDetail', {
    extend: 'Ext.form.FormPanel',
    xtype: 'photoDetail',
    config: {
        //style:'font-size:14px',
        title: '更新分类',
        items: [
            {
                xtype: 'toolbar',
                docked: 'bottom',
                layout: {
                    type: 'hbox',
                    pack: 'end'
                },
                items: [
                    {
                        xtype:"button",
                        id: 'category_edit_submit',
                        iconMask: true,
                        scope: this,
                        cls:'x-button2',
                        text: '审核通过',
                        style: 'float:right',
                        listeners:{
                            tap:function(){
                                Ext.Msg.confirm('确定该图片审核通过?', '', function (data) {
                                    if (data == 'yes') {
                                        Ext.Ajax.request({
                                            url:GLOBAL.api_url+"/photowall_audit",
                                            scope:this,
                                            params:{
                                                id:Ext.getCmp("imgid").getValue()
                                            },
                                            success:function(data){
                                                console.log(data);
                                                Ext.Msg.alert("审核通过!");

                                            },
                                            failure:function(f){
                                                console.log(f);
                                                Ext.Msg.alert("审核失败,稍后再试!");
                                            }
                                        });
                                    }
                                });
                            }
                        }
                    },
                    {
                        id: 'category_del',
                        iconMask: true,
                        scope: this,
                        cls:'x-button2',
                        text: '删除',
                        style: 'float:right',
                        listeners:{
                            tap:function(){
                                Ext.Msg.confirm('确定删除?', '', function (data) {
                                    if (data == 'yes') {
                                        Ext.Ajax.request({
                                            url:GLOBAL.api_url+"/photowall_delete",
                                            scope:this,
                                            params:{
                                                id:Ext.getCmp("imgid").getValue()
                                            },
                                            success:function(data){
                                                console.log(data);
                                                Ext.Msg.alert("删除成功!");
                                            },
                                            failure:function(f){
                                                console.log(f);
                                                Ext.Msg.alert("删除失败,稍后再试!");
                                            }
                                        });
                                    }
                                });
                            }
                        }
                    }
                ]
            },
            {
                xtype:"textfield",
                id:'imgcaption',
                label: '照片描述',
                disabled:true
            },
            {   xtype:'panel',
                id:'imgshow'
            },
            {
                xtype:"hiddenfield",
                id:"imgid"
            }
        ]
    }
});